
$(function () {
    getData();
})
function getData() {
    $.get('./php/getGoodsList.php', function (data) {
        let arr = JSON.parse(data);
        console.log(arr)
        let str = "";
        arr.forEach((item, index) => {
            str += `
                <div class="goods-item" >
                    <a class="goods-box">
                        <div class="item-top">
                            <img src="${item.goodsImg}" goodsid="${item.goodsId}">
                        </div>
                        <!-- 商品信息，价格介绍 -->
                        <div class="item-bottom">
                            <div class="item-price">
                                <div class="cont">
                                    <div class="price-lable">
                                        <span class="txt">特卖价</span>
                                    </div>
                                    <div class="sale-price">
                                        <span>￥</span>
                                        <span class="price-num">${item.goodsPrice}</span>
                                    </div>
                                    <div class="market-price">
                                        <span>￥</span>
                                        <span class="price-num">1999</span>
                                    </div>
                                    <div class="discont">2.8折</div>
                                </div>
                            </div>
                            <div class="item-name">${item.goodsDesc}</div>
                            <ul class="tag-wrap">
                                <li><span>新货上架</span></li>
                            </ul>
                        </div>
                    </a>
                </div>`
        })
        $('.list-inner').html(str)
    })
}
$('.list-inner').on('click', 'img', function (e) {
    if (e.target.nodeName == "IMG") {
        console.log(e.target.getAttribute('goodsId'));
        let id = e.target.getAttribute('goodsId');
        window.open('http://127.0.0.1/test/VIP/big.html?goodsId=' + id);
    }
})
